load("@rules_proto//proto:defs.bzl", "proto_library")

# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

##############################################################################
# Common
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")

proto_library(
    name = "operations_proto",
    srcs = ["operations.proto"],
    deps = [
        "//google/api:annotations_proto",
        "//google/api:client_proto",
        "//google/rpc:status_proto",
        "@com_google_protobuf//:any_proto",
        "@com_google_protobuf//:descriptor_proto",
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:empty_proto",
    ],
)

proto_library_with_info(
    name = "longrunning_proto_with_info",
    deps = [":operations_proto"],
)

##############################################################################
# Java
##############################################################################
load("@com_google_googleapis_imports//:imports.bzl", "java_grpc_library", "java_proto_library")

java_proto_library(
    name = "longrunning_java_proto",
    deps = [":operations_proto"],
)

java_grpc_library(
    name = "longrunning_java_grpc",
    srcs = [":operations_proto"],
    deps = [":longrunning_java_proto"],
)

##############################################################################
# Go
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "go_gapic_assembly_pkg",
    "go_gapic_library",
    "go_proto_library",
    "go_test",
)

go_proto_library(
    name = "longrunning_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "google.golang.org/genproto/googleapis/longrunning",
    protos = [":operations_proto"],
    visibility = ["//visibility:public"],
    deps = [
        "//google/api:annotations_go_proto",
        "//google/rpc:status_go_proto",
    ],
)

go_gapic_library(
    name = "longrunning_go_gapic",
    srcs = [":longrunning_proto_with_info"],
    grpc_service_config = "longrunning_grpc_service_config.json",
    importpath = "cloud.google.com/go/longrunning/autogen;longrunning",
    service_yaml = "//google/longrunning:longrunning.yaml",
    deps = [":longrunning_go_proto"],
)

go_test(
    name = "longrunning_go_gapic_test",
    srcs = [":longrunning_go_gapic_srcjar_test"],
    embed = [":longrunning_go_gapic"],
    importpath = "cloud.google.com/go/longrunning/autogen",
)

# Open Source Packages
go_gapic_assembly_pkg(
    name = "gapi-cloud-longrunning-go",
    deps = [
        ":longrunning_go_gapic",
        ":longrunning_go_gapic_srcjar-test.srcjar",
        ":longrunning_go_proto",
    ],
)

##############################################################################
# C++
##############################################################################
load(
    "@com_google_googleapis_imports//:imports.bzl",
    "cc_grpc_library",
    "cc_proto_library",
)

cc_proto_library(
    name = "longrunning_cc_proto",
    deps = [":operations_proto"],
)

cc_grpc_library(
    name = "longrunning_cc_grpc",
    srcs = [":operations_proto"],
    grpc_only = True,
    deps = [":longrunning_cc_proto"],
)
